//
//  YSGNurseSubscribeViewModel.swift
//  EyeVisionForPatients
//
//  Created by liuyutian on 2022/8/4.
//  Copyright © 2022 QDSG. All rights reserved.
//

import UIKit
import HandyJSON

struct YSGNurseSubscribeModel: HandyJSON {
    var consultCount: Int? = 0
    var deptName: String?
    var doctorId: String?
    var doctorPicture: String?
    var score: String?
    
    var free: String?
    var introduction: String?
    var jobTitle: String?
    var name: String?
    var tbUserId: String?

    
}
struct YSGNurseSubscribeViewModel {
    var models: [YSGNurseSubscribeModel]
    
    
    var numberOfSections: Int { return models.count }
    
    
    func cellHeight(index: Int) -> CGFloat {
        let introduction = models[index].introduction ?? ""
        let h = introduction.height(font: .regular(14), width: screenW - 128)
        
        return 140 + h
    }
    /// 所有项目列表
    static func getNurseSubscribeList(name : String, size :Int,current:Int, finished: @escaping (_ models: [YSGNurseSubscribeModel], _ total: Int, _ errorMsg: String?, _ code: HttpCode) -> Void) {
        

        HttpTool.shared.request(target: ApiManager.appointment_nurse_subscribe(paras: ["name":name,"current":current,"size":size]), success: { (json, code) in
            if let models = JSONDeserializer<YSGNurseSubscribeModel>.deserializeModelArrayFrom(json: json["data"]["records"].description) as? [YSGNurseSubscribeModel] {
                finished(models,json["data"]["total"].intValue, nil, .success)
            } else {
                finished([], 0,json["message"].description, .failure)
            }
        }) { errorMsg in
            finished([],0, errorMsg, .failure)
        }
    }
    
}
